package co.edu.usbcali.prototipobeta.modelo.dto;

import co.edu.usbcali.prototipobeta.modelo.Medicina;
import co.edu.usbcali.prototipobeta.presentation.backingBeans.MedicinaView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class MedicinaDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String medNombre;
    private String bebeId_Bebe;
    private String medId;
    private boolean rowSelected = false;
    private MedicinaView medicinaView;
    private Medicina medicina;

    public Medicina getMedicina() {
        return medicina;
    }

    public String listener_update(ActionEvent e) {
        try {
            medicinaView.action_modifyWitDTO(((medId == null) ||
                medId.equals("")) ? null : new Long(medId),
                ((medNombre == null) || medNombre.equals("")) ? null
                                                              : new String(
                    medNombre),
                ((bebeId_Bebe == null) || bebeId_Bebe.equals("")) ? null
                                                                  : new Long(
                    bebeId_Bebe));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        medId = medicina.getMedId().toString();
        medNombre = (medicina.getMedNombre() != null)
            ? medicina.getMedNombre().toString() : null;
        bebeId_Bebe = (medicina.getBebe().getBebeId() != null)
            ? medicina.getBebe().getBebeId().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Object details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        medId = medicina.getMedId().toString();
        medNombre = (medicina.getMedNombre() != null)
            ? medicina.getMedNombre().toString() : null;
        bebeId_Bebe = (medicina.getBebe().getBebeId() != null)
            ? medicina.getBebe().getBebeId().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setMedicina(Medicina medicina) {
        this.medicina = medicina;
    }

    public MedicinaView getMedicinaView() {
        return medicinaView;
    }

    public void setMedicinaView(MedicinaView medicinaView) {
        this.medicinaView = medicinaView;
    }

    public String getMedNombre() {
        return medNombre;
    }

    public void setMedNombre(String medNombre) {
        this.medNombre = medNombre;
    }

    public String getBebeId_Bebe() {
        return bebeId_Bebe;
    }

    public void setBebeId_Bebe(String bebeId_Bebe) {
        this.bebeId_Bebe = bebeId_Bebe;
    }

    public String getMedId() {
        return medId;
    }

    public void setMedId(String medId) {
        this.medId = medId;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
